﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.Distribution.Dto
@using FwProject.Core.Distribution
@model IPagedList<DistributionTypeNumberReportDto>
@{
    Layout = null;
    int count = 0;
    int SumDistributioncount = 0;
    int SumDistributionBycount = 0;
    int SumRecoverycount = 0;
    int SumRecoveryBycount = 0;
    int SumExchangegoodscount = 0;
    int SumExchangegoodsBycount = 0;
    int SumDamagecount = 0;
    int SumGivecount = 0;
    int SumGiveBycount = 0;
    int SumBackboxcount = 0;
    int SumBacknumbercount = 0;
    int x = 0;
    if (Model.Count > 0)
    {
        if (Model.PageNumber != 1)
        {

            x = (Model.PageNumber - 1) * Model.PageSize;
        }
    }
}
<div id="table_print2" style="max-height:600px;overflow-y:scroll;">

    <table class="table table-bordered table-hover table-rowselected">
        <thead>
            <tr>
                <th style="width:45px">序号</th>
                <th>司机</th>
                <th>货品型号</th>
                <th>配送箱数</th>
                <th>配送套数</th>
                <th>回收箱数</th>
                <th>回收套数</th>
                <th>换货箱数</th>
                <th>换货套数</th>
                <th>折损套数</th>
                <th>赠送箱数</th>
                <th>赠送套数</th>
                <th>退回箱数</th>
                <th>退回套数</th>
            </tr>
        </thead>
        <tbody>
            @if (Model.Count == 0)
            {
                <tr><td class="text-center" colspan="10">暂无信息</td></tr>
            }
            else
            {
                foreach (var item in Model)
                {
                    x++;
                    count = item.TypeNumberModelList.Count;
                    if (count > 0)
                    {
                        SumDistributioncount += item.TypeNumberModelList.Sum(o => o.Distributioncount);
                        SumDistributionBycount += item.TypeNumberModelList.Sum(o => o.DistributionNumbercount);
                        SumRecoverycount += item.TypeNumberModelList.Sum(o => o.Recoverycount);
                        SumRecoveryBycount+= item.TypeNumberModelList.Sum(o => o.RecoveryNumbercount);
                        SumExchangegoodscount += item.TypeNumberModelList.Sum(o => o.Exchangegoodscount);
                        SumExchangegoodsBycount += item.TypeNumberModelList.Sum(o => o.ExchangegoodsNumbercount);
                        SumDamagecount += item.TypeNumberModelList.Sum(o => o.Damagecount);
                        SumGivecount += item.TypeNumberModelList.Sum(o => o.Givecount);
                        SumGiveBycount+= item.TypeNumberModelList.Sum(o => o.GiveNumbercount);
                        SumBackboxcount += item.TypeNumberModelList.Sum(o => o.Backboxcount);
                        SumBacknumbercount += item.TypeNumberModelList.Sum(o => o.Backnumbercount);

                        for (int i = 0; i < item.TypeNumberModelList.Count; i++)
                        {
                <tr>
                    @if (i == 0)
                    {
                        <td rowspan="@count">@x</td>
                        <td rowspan="@count">@item.DriverName</td>
                    }
                    <td>@item.TypeNumberModelList[i].Name</td>
                    <td>@item.TypeNumberModelList[i].Distributioncount</td>
                    <td>@item.TypeNumberModelList[i].DistributionNumbercount</td>
                    <td>@item.TypeNumberModelList[i].Recoverycount</td>
                    <td>@item.TypeNumberModelList[i].RecoveryNumbercount</td>
                    <td>@item.TypeNumberModelList[i].Exchangegoodscount</td>
                    <td>@item.TypeNumberModelList[i].ExchangegoodsNumbercount</td>
                    <td>@item.TypeNumberModelList[i].Damagecount</td>
                    <td>@item.TypeNumberModelList[i].Givecount</td>
                    <td>@item.TypeNumberModelList[i].GiveNumbercount</td>
                    <td>@item.TypeNumberModelList[i].Backboxcount</td>
                    <td>@item.TypeNumberModelList[i].Backnumbercount</td>
                </tr>
                        }
                    }
                }
                <tr class="footer">
                    <td style="color:red">合计</td>
                    <td colspan="2"></td>
                    <td style="color:red">@SumDistributioncount</td>
                    <td style="color:red">@SumDistributionBycount</td>
                    <td style="color:red">@SumRecoverycount</td>
                    <td style="color:red">@SumRecoveryBycount</td>
                    <td style="color:red">@SumExchangegoodscount</td>
                    <td style="color:red">@SumExchangegoodsBycount</td>
                    <td style="color:red">@SumDamagecount</td>
                    <td style="color:red">@SumGivecount</td>
                    <td style="color:red">@SumGiveBycount</td>
                    <td style="color:red">@SumBackboxcount</td>
                    <td style="color:red">@SumBacknumbercount</td>
                </tr>
            }
        </tbody>
    </table>

</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        @*共 @Model.TotalItemCount 条，@Model.PageSize 条/页 当前第 @Model.PageNumber/@Model.PageCount 页*@
        共 @Model.TotalItemCount 条，
        <select class="form-control" id="pageSize2" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select> &nbsp;条/页 当前第 @Model.PageNumber/@Model.PageCount 页
    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&DriverName=@(Context.Request.Query["DriverName"])&beginTime2=@(Context.Request.Query["beginTime2"])&endTime2=@(Context.Request.Query["endTime2"])&key=2" />
        @Html.PagedListPager(Model, page => Url.Action("DriverDistribution", new { pageIdx = page, size2 = Context.Request.Query["size2"], DriverName = Context.Request.Query["DriverName"], beginTime2 = Context.Request.Query["beginTime2"], endTime2 = Context.Request.Query["endTime2"], key = 2 }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list2", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>